package com.whutosa.template.server.interceptor;

import com.whutosa.template.server.model.Person;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 19110 on 2017/1/7.
 */
@Component
public class AddFieldInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Person p = new Person();
        p.setName(request.getParameter("token"));
        request.setAttribute("person", p);
        return super.preHandle(request, response, handler);
    }
}
